<template>
	<a-card :title="title" :bordered="false">
		<a-flex gap="small">
			<div class="container" @click="leaveFor(item.router)" :key="item.key" v-for="item in dataSource">
				<a-flex style="align-items: center">
					<a-tag :color="item.color" class="container-tag">
						<component :is="item.icon" class="container-tag-icon" />
					</a-tag>
					<div>
						<span style="font-weight: 700; font-size: 18px">{{ item.number }}</span>
						<br />
						<span>{{ item.title }}</span>
					</div>
				</a-flex>
			</div>
		</a-flex>
	</a-card>
</template>

<script setup name="bizIndexFlwProcessCard">
	import indexApi from '@/api/flw/indexApi'
	import router from '@/router'
	const title = ref('我的待办')
	const dataSource = ref([
		{
			key: 'draftNum',
			icon: 'EditFilled',
			color: '#1677FF',
			number: 0,
			title: '我的草稿',
			router: '/flw/newTask'
		},
		{
			key: 'applyNum',
			icon: 'FlagFilled',
			color: '#e018ff',
			number: 0,
			title: '已发申请',
			router: '/flw/myApply'
		},
		{
			key: 'todoNum',
			icon: 'QuestionCircleFilled',
			color: '#FCC02E',
			number: 0,
			title: '待办事宜',
			router: '/flw/todoTask'
		},
		{
			key: 'doneNum',
			icon: 'SafetyCertificateFilled',
			color: '#52C41A',
			number: 0,
			title: '已办事宜',
			router: '/flw/doneTask'
		},
		{
			key: 'copyNum',
			icon: 'MailFilled',
			color: '#ec2c09',
			number: 0,
			title: '抄送事宜',
			router: '/flw/copyTask'
		}
	])
	onMounted(() => {
		indexApi.indexFlwIndicator().then((data) => {
			dataSource.value.forEach((item) => {
				item.number = data[item.key]
			})
		})
	})
	// 跳转，用于点击
	const leaveFor = (url = '/') => {
		router.replace({ path: url })
	}
</script>

<style scoped>
	.container {
		padding: 10px;
		width: 100%;
		/*border: 1px solid #eaeaea;*/
		border-radius: 2px;
		display: flex;
		align-items: center;
		cursor: pointer;
		/*实现渐变（时间变化效果）*/
		-webkit-transition: all 0.5s;
		-moz-transition: all 0.5s;
		-ms-transition: all 0.5s;
		-o-transition: all 0.5s;
		transition: all 0.5s;
	}
	.container:hover {
		background: var(--border-color-split);
	}
	:deep(.ant-card-body) {
		padding-top: 0 !important;
	}
	.container-tag {
		width: 45px;
		height: 45px;
		border-radius: 50px;
		display: flex;
		align-items: center;
		margin-left: 12px;
		justify-content: center;
	}
	.container-tag-icon {
		font-size: 20px;
	}
</style>
